//
//  BaseNavigationController.swift
//  FoundationsAppCode
//
//  Created by Erickson on 16/3/18.
//  Copyright © 2016年 paiyipai. All rights reserved.
//

import UIKit

class BaseNavigationController: UINavigationController {

    override class func initialize(){
        
        
        UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName:UIFont.systemFont(ofSize: 16),NSForegroundColorAttributeName:UIColor.darkGray], for: UIControlState()) //可以同时设置letfbarButton和rightBarButtonItem的颜色。但是返回箭头的颜色还是系统的蓝色
        
        
        let navBar =  UINavigationBar.appearance()
        
        navBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.darkGray,NSFontAttributeName:UIFont.systemFont(ofSize: 18)]
        
//        navBar.tintColor = UIColor.darkGray
        navBar.isTranslucent = false
//        navBar.barTintColor = ConstantColor.appThemeColor
        
        let tabbar = UITabBarItem.appearance()
        tabbar.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.black], for: UIControlState())
        tabbar.setTitleTextAttributes([NSForegroundColorAttributeName:ConstantColor.appThemeColor], for: .selected)
        
        
        UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(-1000, 0), for: .default)
       
        navBar.backIndicatorImage = UIImage(named: "back")?.withRenderingMode(.alwaysOriginal)
        navBar.backIndicatorTransitionMaskImage = UIImage(named: "back")?.withRenderingMode(.alwaysOriginal)
        
        navBar.setBackgroundImage(UIImage(), for: .any, barMetrics: .default)
        navBar.shadowImage = UIColor.imageWithColor(UIColor(hex:0xbd9190), size: CGSize(width: AppConstant.screenWidth, height: 0.5))
        
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        if viewControllers.count>0 {
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: animated)
    }
    
    override var preferredStatusBarStyle : UIStatusBarStyle {
        return .default
    }

    
}
